import Requests from "./index"
import type { account } from "./type"

// 登录
export const Login = (data: account) =>
  Requests.post({ url: "/auth/login", data })

// 退出
export const Logout = () => Requests.post({ url: "/auth/logout" })

// 初始化菜单
export const GetInit = () => Requests.get({ url: "/common/init" })

// 获取所属菜单（菜单管理）
export const GetOptionMenu = () => Requests.get({ url: "common/menu" })

// 获取所属菜单（权限管理）
export const GetOptionPerm = () => Requests.get({ url: "common/perm" })

// 获取所有角色
export const GetOptionRoles = () => Requests.get({ url: "common/roles" })

// 获取权限树
export const GetOptionRoleTree = () => Requests.get({ url: "common/tree" })

// 获取角色权限
export const GetOptionRole = (id: number) =>
  Requests.get({ url: `common/role/${id}` })

// 以上为公共接口

// 获取页面信息
export const GetPageInfo = (url: string, params?: any) =>
  Requests.get({ url: url, params })

// 新建信息
export const AddPageInfo = (url: string, data?: any) =>
  Requests.post({ url: url, data })

// 编辑信息
export const EditPageInfo = (url: string, data?: any) =>
  Requests.put({ url: url, data })

// 删除信息
export const DeletePageData = (url: string) => Requests.delete({ url: url })

// 分配权限
export const PermRole = (id: number, data: any) => {
  console.log(data)

  return Requests.put({ url: `role/perm/${id}`, data })
}
